<template>
	<view>
		<!-- 接任务 -->
		<nt-card label="">
			<view class="payment-card__remarks">
				<u--textarea v-model="remarks" placeholder="请输入备注或所在地址"></u--textarea>
			</view>
			
			<nt-card-item label="上传图片"></nt-card-item>
			<nt-upload @success="UpImages = $event" :images="images"></nt-upload>
		</nt-card>
		<view class="h_btn">
			<view @tap="submit">提交</view>
		</view>
	</view>
</template>

<script>
import {postTask,getTaskDetails} from "@/api"
	export default {
		data() {
			return {
				id: 0,
				remarks: "",
				images:[],
				UpImages: [],
			}
		},
		onLoad(options) {
			this.id = options.id
			this.getDetails()
		},
		methods: {
			submit(){
				let UpImages = this.UpImages
				let imgUrls = UpImages.map(item => (item.url))
				let parmas = {
					"id": this.id, 
					"remarks": this.remarks, 
					"images": imgUrls
				}
				postTask(parmas).then(res => {
					const { code, msg } = res;
					if(code !== 1) return;
					this.toast("提交成功")
					setTimeout(() => {
						uni.redirectTo({
							url:'./index'
						})
					}, 1000)
				})
			},
			getDetails(){
				let id = this.id
				getTaskDetails({id:id}).then(res => {
					const { code,data,msg } = res;
					if(data.myorder){
						this.remarks = data.myorder.remarks
						this.images = data.myorder.images
					}
					
				})
			}
		}
	}
</script>

<style lang="scss">
	// page{background: #F2F4F6;}
	.h_btn{
		padding: 20px;
		view{
			line-height:76rpx;
			background:#1B5BC5;
			text-align: center;
			color: #fff;
			border-radius: 46rpx;
		}
	}
</style>
